home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / SHELL_EX.BAS < prev    next >
BASIC Source File  |  1988-09-17  |  1KB  |  46 lines

  1. ' *** SHELL_EX.BAS ***
  2. '
  3. DECLARE FUNCTION GetName$ (DirLine$)
  4. LINE INPUT "Enter target drive and directory: ",PathSpec$
  5. SHELL "DIR > DIRFILE"     'Store directory listing in DIRFILE.
  6. DO
  7.    OPEN "DIRFILE" FOR INPUT AS #1
  8.    INPUT "Enter date (MM-DD-YY): ",MDate$
  9.    PRINT
  10.    ' Read DIRFILE, test for input date.
  11.    DO
  12.       LINE INPUT #1, DirLine$
  13.       ' Test directory line to see if date matches and the line
  14.       ' is not one of the special directories ( . or .. ).
  15.       IF INSTR(DirLine$,MDate$) > 0 AND LEFT$(DirLine$,1) <> "." THEN
  16.      FileSpec$ = GetName$(DirLine$)
  17.      ' Don't move temporary file.
  18.      IF FileSpec$ <> "DIRFILE" THEN
  19.         ' Build DOS command line to copy file.
  20.         DoLine$ = "COPY " + FileSpec$ + "  " + PathSpec$
  21.         PRINT DoLine$
  22.         ' Copy file.
  23.         SHELL DoLine$
  24.      END IF
  25.       END IF
  26.    LOOP UNTIL EOF(1)
  27. CLOSE #1
  28.    PRINT "New date?"
  29.    R$ = INPUT$(1)
  30.    CLS
  31. LOOP UNTIL UCASE$(R$) <> "Y"
  32. ' KILL "DIRFILE".
  33. END
  34.  
  35. FUNCTION GetName$ (DirLine$) STATIC
  36. ' This function gets the file name and extension from
  37. ' the directory-listing line.
  38.    BaseName$ = RTRIM$(LEFT$(DirLine$,8))
  39.    ' Check for extension.
  40.    ExtName$  = RTRIM$(MID$(DirLine$,10,3))
  41.    IF ExtName$ <> "" THEN
  42.       BaseName$ = BaseName$ + "." + ExtName$
  43.    END IF
  44.    GetName$ = BaseName$
  45. END FUNCTION
  46.